<?php

class AdminModule extends CWebModule {

    public $moduleLabel = '';

    public function init() {
        $this->setImport(array(
            'admin.models.*',
            'admin.components.*',
        ));
        //correct the layout path. 
        //$this->setLayoutPath( dirname(__FILE__).'/views/layouts/' );

        Yii::app()->name = 'Opendev -CPanel';
        Yii::app()->language = 'vi';
        Yii::app()->timezone = 'Asia/Ho_Chi_Minh';

        $this->defaultController = 'privilege';
        $this->moduleLabel = Yii::app()->name;

        //change component with customer class.
        $adminSession = new AdminSession();
        $adminSession->setSessionName(Yii::app()->params['area']['admin'] . '_SESSION');
        Yii::app()->setComponent('session', $adminSession);

        Yii::app()->setComponent('admin', new WebAdmin());
        Yii::app()->admin->setReturnUrl(Yii::app()->createAbsoluteUrl('admin/privilege/index'));
        //Yii::app()->setHomeUrl( Yii::app()->createAbsoluteUrl('adminhtml/privilege/index') );

        Yii::app()->getErrorHandler()->errorAction = 'admin/privilege/error';
    }

    public function beforeControllerAction($controller, $action) {
        if (parent::beforeControllerAction($controller, $action)) {
            // this method is called before any module controller action is performed
            // you may place customized code here
            return true;
        }
        else
            return false;
    }

}
